const CompressionPlugin = require("compression-webpack-plugin");

module.exports = {
  runtimeCompiler: true,
  //关闭eslint
  lintOnSave: false,
    // 现场? "/etmspc" ； 测试? "./"
  publicPath: process.env.NODE_ENV === "production" ? "/etmspc" : "/",
  assetsDir: "static",
  productionSourceMap: false,
  outputDir: process.env.outputDir,
  configureWebpack: config => {
    if (process.env.NODE_ENV === "production") {
      return {
        plugins: [
          new CompressionPlugin({
            // test: /\.js$|\.html$|\.css/,
            test: /\.(js|css|svg|woff|ttf|json|html)$/,
            threshold: 10240,
            deleteOriginalAssets: false
          })
        ]
      };
    }
  },
  devServer: {
    host: "0.0.0.0",
    port: 8000, // 端口号
    https: false, // https:{type:Boolean}
    open: true, //配置自动启动浏览器  http://XXX.XXX.X.XX:7071/rest/XXX/
    hotOnly: true // 热更新
  },
  configureWebpack: {
    externals: {
      BMap: "BMap"
    }
  }
};
